﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LingDong.QueryCore;
using NLog;

namespace LingDong.QueryExample
{
    class QueryRunner
    {
        internal void Run()
        {
            Query.Init();
            logger = LogManager.GetCurrentClassLogger();

            TestQuery("北京 北大");
        }

        private void TestQuery(string query)
        {
            DateTime start = DateTime.Now;
            logger.Debug("Query for: {0}", query);

            List<QueryResultEntity> result = Query.GetQueryResult(query);
            logger.Debug("Result number: {0}", result.Count);
            foreach (QueryResultEntity entity in result)
            {
                logger.Trace(entity.ToString());
            }

            TimeSpan usedTime = DateTime.Now - start;
            logger.Debug(usedTime.ToString());
        }

        private Logger logger;
    }
}
